﻿using Max.PH4_2102A.Shopping.DAL;
using Max.PH4_2102A.Shopping.Domain;
using Max.PH4_2102A.Shopping.IRespository;

namespace Max.PH4_2102A.Shopping.Respository
{
    public class UserRespository : IUserRespository
    {
        EFCoreHelper _db;
        public UserRespository(EFCoreHelper db)
        {
            _db = db;
        }

        public IQueryable<UserModel> GetAll()
        {
            IQueryable<UserModel> list = _db.Users;
            return list;
        }

        public int Insert(UserModel model)
        {
            _db.Users.Add(model);
            int result = _db.SaveChanges();
            return result;
        }

        public int Update(UserModel model)
        {
            _db.Users.Update(model);
            int result = _db.SaveChanges();
            return result;

        }
    }
}